
<template>
	<view>
		<view class="mainpadding flexbetween" @click="jumpurl('/pages/mine/bangdingzfb?type=3')">
			<view class="main_size hei_text">绑定支付宝</view>
			<u-icon name="arrow-right" color="#999" size="16"></u-icon>
		</view>
		<view class="mainpadding flexbetween" @click="wxlogin">
			<view class="main_size hei_text">绑定微信</view>
			<u-icon name="arrow-right" color="#999" size="16"></u-icon>
		</view>
		<view class="mainpadding flexbetween" @click="jumpurl('/pages/system/system?type=3')">
			<view class="main_size hei_text">关于我们</view>
			<u-icon name="arrow-right" color="#999" size="16"></u-icon>
		</view>
		<view class="mainpadding flexbetween" @click="jumpurl('/pages/system/system?type=2')">
			<view class="main_size hei_text">隐私政策</view>
			<u-icon name="arrow-right" color="#999" size="16"></u-icon>
		</view>
		<view class="mainpadding flexbetween" @click="jumpurl('/pages/system/system?type=1')">
			<view class="main_size hei_text">用户协议</view>
			<u-icon name="arrow-right" color="#999" size="16"></u-icon>
		</view>
		<view class="mainpadding flexbetween" @click="zxBtn">
			<view class="main_size hei_text">注销</view>
			<u-icon name="arrow-right" color="#999" size="16"></u-icon>
		</view>
		<!-- <view class="mainpadding flexbetween" @click="jumpurl('/pages/system/system?type=4')">
			<view class="main_size hei_text">信誉积分规则说明</view>
			<u-icon name="arrow-right" color="#999" size="16"></u-icon>
		</view>
		<view class="mainpadding flexbetween" @click="jumpurl('/pages/mine/xinyujfmx')">
			<view class="main_size hei_text">信誉积分明细</view>
			<u-icon name="arrow-right" color="#999" size="16"></u-icon>
		</view> -->
		<view class="posibottom mainpadding">
			<view class="submitbtn" @click="modal.modalShow=true">退出登录</view>
		</view>
		<moDal :message="modal" @modalSure="modalSure" @modalcancel="modalcancel"></moDal>
	</view>
</template>

<script>
	const httpRequest = require("@/common/httpRequest.js")
	export default {
		data() {
			return {
				modal: {
					modalShow: false,
					title: "是否确认退出登录？",
				}
			}
		},
		methods: {
			zxBtn(){
				this.modal.title = "是否确认注销?"
				this.modal.modalShow = true
				
			},
			wxlogin() {
				let _this = this
				// #ifdef APP-PLUS
				uni.login({
					provider: "weixin",
					"onlyAuthorize": true, // 微信登录仅请求授权认证
					success: function (loginRes) {
						console.log(loginRes,"hahai");
						console.log(uni.getStorageSync("token"));
						_this.wxbangding(loginRes.code)
					},fail(err) {
						console.log(err,"vuowu");
					}
				});
				// #endif
				
				// #ifdef MP-WEIXIN
					uni.login({
						success(res) {
							if (res.code) {
								_this.wxbangding(res.code)
							}
						}
					})
				// #endif
			},
			wxbangding(code){
				let platform = "wxmini"
				// #ifdef APP-PLUS
				platform = "wxopen"
				// #endif
				httpRequest.request('/api/user/wxlogin', 'GET', {
					code:code,
					platform,
				}).then(resp => {
					console.log(resp,"jinglei");
					httpRequest.toast(resp.msg)
				})
			},
			modalSure() {
				if (this.modal.title == "是否确认退出登录？") {
					uni.removeStorageSync('isJzdyToast');
					uni.removeStorageSync('token');
					uni.removeStorageSync('user_id');
					httpRequest.toast("退出登录成功")
					setTimeout(() => {
						uni.navigateBack(1)
					}, 1000)
				}else{
					httpRequest.request('/api/user/zxUser', 'GET', {
						
					}).then(resp => {
						if(resp.code==1){ 
						
							uni.removeStorageSync('isJzdyToast');
							uni.removeStorageSync('token');
							uni.removeStorageSync('user_id');
							httpRequest.toast(resp.msg)
							setTimeout(() => {
								uni.navigateBack(1)
							}, 1000)
						}else{
							httpRequest.toast(resp.msg)
						}
					})
				}
				this.modalcancel()
			},
			modalcancel() {
				this.modal.modalShow = false
			},
			jumpurl(url) {
				uni.navigateTo({
					url
				})
			}
		}
	}
</script>

<style>

</style>